package uk.ac.manchester.cs.graph;

import java.util.Collection;
import java.util.HashSet;
import java.util.Set;

/**
 * 
 * @author Pavel Klinov
 *
 * pklinov@cs.man.ac.uk, pklinov@clarkparsia.com
 * 
 * Feb 3, 2009
 */
public class HyperedgeImpl<V, E> implements Hyperedge<V, E> {

	private E m_object = null;
	private Set<V> m_vertices = new HashSet<V>();
	
	public HyperedgeImpl() {}
	
	public HyperedgeImpl(E object) {
		
		m_object = object;
	}

	public E getObject() {
		
		return m_object;
	}
	
	public HyperedgeImpl(Collection<? extends V> vertices) {
		
		m_vertices.addAll(vertices);
	}
	
	public HyperedgeImpl(E object, Collection<V> vertices) {
		
		m_object = object;
		m_vertices.addAll(vertices);
	}	
	
	public Set<V> getVertices() {

		return  m_vertices;
	}

	public void setVertices(Set<V> vertices) {

		m_vertices.clear();
		m_vertices.addAll( vertices );
	}	
	
	public void removeVertex(V vertex) {
		
		m_vertices.remove( vertex );
	}
	
	protected void addVertex(V vertex) {
	
		m_vertices.add( vertex );
	}

	@Override
	public String toString() {
		
		return "E" + m_object + ": " + m_vertices.toString();
	}
}
